package com.io;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;

public class Person implements Serializable {
    private String name;
    private int age;
    private String gender;

    // 在Person类的成员变量声明中，使用transient关键字修饰String数组occupation
    // private transient String[] occupation;
    private  String[] occupation;


    public Person() {
    }

    public Person(String name, int age, String gender, String[] occupation) {
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.occupation = occupation;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String[] getOccupation() {
        return occupation;
    }

    public void setOccupation(String[] occupation) {
        this.occupation = occupation;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", gender='" + gender + '\'' +
                ", occupation=" + Arrays.toString(occupation) +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return age == person.age && Objects.equals(name, person.name) && Objects.equals(gender, person.gender) && Arrays.equals(occupation, person.occupation);
    }

    @Override
    public int hashCode() {
        int result = Objects.hash(name, age, gender);
        result = 31 * result + Arrays.hashCode(occupation);
        return result;
    }
}
